package com.haixiaoke.saas.apartment.mapper;

import com.haixiaoke.saas.apartment.domain.HousingAllocation;
import com.haixiaoke.saas.house.domain.House;
import com.haixiaoke.saas.system.domain.SysArea;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 房屋配置Mapper接口
 *
 * @author panda
 * @date 2024-03-21
 */
public interface HousingAllocationMapper {
    /**
     * 查询房屋配置
     *
     * @param allocationId 房屋配置主键
     * @return 房屋配置
     */
    HousingAllocation selectHousingAllocationByAllocationId(Long allocationId);

    /**
     * 查询房屋配置列表
     *
     * @param housingAllocation 房屋配置
     * @return 房屋配置集合
     */
    List<HousingAllocation> selectHousingAllocationList(HousingAllocation housingAllocation);

    /**
     * 新增房屋配置
     *
     * @param housingAllocation 房屋配置
     * @return 结果
     */
    int insertHousingAllocation(HousingAllocation housingAllocation);

    /**
     * 修改房屋配置
     *
     * @param housingAllocation 房屋配置
     * @return 结果
     */
    int updateHousingAllocation(HousingAllocation housingAllocation);

    /**
     * 删除房屋配置
     *
     * @param allocationId 房屋配置主键
     * @return 结果
     */
    int deleteHousingAllocationByAllocationId(Long allocationId);

    /**
     * 批量删除房屋配置
     *
     * @param allocationIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteHousingAllocationByAllocationIds(Long[] allocationIds);

    /**
     * 根据房屋id查询房屋配置
     * @param houseId 房屋id
     * @return
     */
    HousingAllocation selectHousingAllocationByHouseId(String houseId);

    int softDeleteHousingAllocationByAllocationId(Long allocationId);

    /**
     * 统计改房屋下房屋配置的数据
     * @param houseId
     * @return
     */
    int checkAllocationByHouse(String houseId);

    /**
     * 统计上下架数量，未配置数量    1上架2下架3未配置
     * @return
     */
    int countByState(@Param("flag") int flag, @Param("tenantId") String tenantId);

    /**
     * 编辑状态
     * @param allocation
     * @return
     */
    int updateHousingAllocationState(HousingAllocation allocation);

    /**
     * 价格日历列表查询房屋信息
     * @param allocation
     * @return
     */
    List<HousingAllocation> selectCalendarPriceListByAllocation(HousingAllocation allocation);

    @MapKey("house_id")
    Map<String, Map<String, Object>> selectAllocationIdAndHouseId(String[] houseIds);

    /**
     * 小程序首页筛选分页
     * @param housingAllocation
     * @return
     */
    List<HousingAllocation> selectHousingAllocationHomePage(HousingAllocation housingAllocation);
    List<HousingAllocation> selectHousingAllocationHomePageList(HousingAllocation housingAllocation);

    /**
     * 公寓小程序查看房间详情
     */
    HousingAllocation flatSelectHousingAllocationByHouseId(String houseId);

    int addBrowseNum(Long allocationId);

    List<HousingAllocation> selectHouseByAllocation(House house);

    /**
     * 根据房屋id集合查询房屋配置集合
     *
     * @param houseIds
     * @return
     */
    List<HousingAllocation> selectAllocationByHouseIds(List<String> houseIds);

    List<SysArea> selectHousingAllocationArea();

}
